//
//  LTSelectPhotoView.m
//  LTChat
//
//  Created by 俊松何 on 2017/7/28.
//  Copyright © 2017年 俊松何. All rights reserved.
//

#import "LTSelectPhotoView.h"
#import "KLCPopup.h"
@interface LTSelectPhotoView ()
//50 * 3 + 10 + 1
@property (weak, nonatomic) IBOutlet UIButton *talkPhotonButton;

@property (weak, nonatomic) IBOutlet UIButton *pictureButton;

@property (weak, nonatomic) IBOutlet UIButton *cancelButton;

@property(nonatomic,strong) KLCPopup *pop;

@end

@implementation LTSelectPhotoView

-(void)awakeFromNib
{
    [super awakeFromNib];
    [self.talkPhotonButton setTitle:NSLTLocalizedString(@"personInfo.takePhoto", nil) forState:UIControlStateNormal];
    [self.pictureButton setTitle:NSLTLocalizedString(@"personInfo.selectPhoto", nil) forState:UIControlStateNormal];
    [self.cancelButton setTitle:NSLTLocalizedString(@"main.cancle", nil) forState:UIControlStateNormal];
    
}

+(instancetype)ltselectView
{
    
    NSBundle *bud = [NSBundle mainBundle];
    NSArray *arry = [bud loadNibNamed:NSStringFromClass(self) owner:nil options:nil];
    LTSelectPhotoView *view = arry.lastObject;
    view.frame = CGRectMake(0, 0,  WIDTH,  161);
    return view;

}

-(void)show
{
    KLCPopup *newpop = [KLCPopup popupWithContentView:self];
    newpop.showType = KLCPopupShowTypeSlideInFromBottom;
    newpop.dismissType = KLCPopupDismissTypeSlideOutToBottom;
    newpop.maskType = KLCPopupMaskTypeClear;
    self.pop = newpop;
    
    [newpop showAtCenter:CGPointMake(WIDTH/2.0, HEIGHT - self.frame.size.height/2) inView:[[UIApplication sharedApplication].delegate window]];
}

-(void)setIsGender:(BOOL)isGender
{
    _isGender = isGender;
    
    [self.pictureButton setTitle:NSLTLocalizedString(@"personInfo.male", nil) forState:UIControlStateNormal];
    [self.talkPhotonButton setTitle:NSLTLocalizedString(@"personInfo.famale", nil) forState:UIControlStateNormal];
    
}

-(void)dismis
{
    [self.pop dismiss:YES];
}

- (IBAction)cancleButton:(UIButton *)sender {
//
    
     [self dismis];
    
    
}
- (IBAction)selectPictureClick:(UIButton *)sender {

       [self dismis];
    
    if(self.isGender){
        if(self.delegate && [self.delegate respondsToSelector:@selector(selectBoyViewSelectPhoto:)]){
            [self.delegate selectBoyViewSelectPhoto:self];
        }
    
    }else{
        if(self.delegate && [self.delegate respondsToSelector:@selector(selectPhotoViewSelectPhoto:)]){
             [self.delegate selectPhotoViewSelectPhoto:self];
        }
    }

   
    
}
- (IBAction)talkPhotoClick:(UIButton *)sender {

       [self dismis];
    if(self.isGender){
        if(self.delegate && [self.delegate respondsToSelector:@selector(selectGrilViewSelectPhoto:)]){
            [self.delegate selectGrilViewSelectPhoto:self];
        }
        
    }else{
    
        if(self.delegate && [self.delegate respondsToSelector:@selector(talkPhotoViewSelectPhoto:)]){
                [self.delegate talkPhotoViewSelectPhoto:self];
        }
    }
}

@end
